package photorganizer.common.helper;

import photorganizer.common.exception.TechnicalException;

public class ClassHelper {

	public static <T> T newInstance(Class<T> clazz) {
		try {
			return clazz.newInstance();
		}
		catch (InstantiationException e) {
			throw new TechnicalException(e);
		}
		catch (IllegalAccessException e) {
			throw new TechnicalException(e);
		}
	}

	public static Object newInstance(String className) {
		try {
			Class<?> clazz = Class.forName(className);
			return newInstance(clazz);
		}
		catch (ClassNotFoundException e) {
			throw new TechnicalException(e);
		}
	}

	private ClassHelper() {
		assert false;
	}

}
